﻿using System;
using System.Data;
using CoreLab.Oracle; //using Devart.Data.Oracle; //using Oracle.DataAccess.Client;
using System.Web;
using System.Web.Caching;


using LMD.Constant;
using LMD.Lib.Oracle;

namespace Cached
{
    /// <summary>
    /// Summary description for EventTemaTable
    /// </summary>
    public class EventTemaTable : CacheAbstraction
    {
        public DataTable GetTema()
        {
            return GetTema(false);
        }
        public DataTable GetTema(bool bForceRefresh)
        {
            String sxCacheKey = KCache.FILTER_TEMA;

            if (bForceRefresh)
            {
                HttpRuntime.Cache.Remove(sxCacheKey);
            }
            if (HttpRuntime.Cache[sxCacheKey] == null)
            {
                DBLib dbl = new DBLib();

                String sxQuery =
                @"
                select
                    T_RELATION_EVENT_ID,
                    CODE
                from
                    T_RELATION_EVENT
                order by
                    CREATE_DATE desc";

                DataTable dt = dbl.GetDataTable(sxQuery);
                AddToCache(sxCacheKey, dt, CacheType.FiveMinutes);

            }
            return (DataTable)HttpRuntime.Cache[sxCacheKey];
        }

        public override String GetCacheFilename()
        {
            return KCache.Filename.FILTER_TEMA;
        }
    }
}